package com.ruoyi.vstac.config;

import com.ruoyi.vstac.domain.Deadline;
import com.ruoyi.vstac.mapper.DeadlineMapper;
import com.ruoyi.vstac.service.DeadlineService;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.Async;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import java.util.Date;

@Configuration
public class StartupConfig {
    @Resource
    private DeadlineService deadlineService;

    public static final String UPDATE_DEADLINE = "UPDATE_DEADLINE";
    public static final String REVIEW_DEADLINE = "REVIEW_DEADLINE";

    /**
     * 在应用启动时从数据库中获取截止日期并将其存入Redis
     */
    @Async
    @PostConstruct
    public void ininDeadline(){
        Deadline deadline = deadlineService.getDeadline();
        deadlineService.setDeadlineToRedis(deadline);
    }
}
